
#ifndef _TLSCONTROLLER_H_
#define _TLSCONTROLLER_H_

#include <string>
#include <map>

namespace localview {
class LocalView;
class Network;
}

class CaseFuzzy;

class TimeIncrementCalculationStrategy;

class TLSController {

public:
	TLSController(std::string strategy, std::string tlsId, localview::Network* network);

	virtual ~TLSController();

	/**
	 * Create a new thread to calculate green time increment for the phase identified by phaseId
	 *
	 * @param phaseId Integer that identify the phase which extension must be calculated
	 */
	void startPhaseIncrementCalc(int phaseId, int timestep);

	/**
	 * TODO document
	 */
	int getPhaseIncrement(int phaseId);

protected:

	/**
	 * TODO document
	 */
	void registerBackgroundCalcTask(TimeIncrementCalculationStrategy* tics, int phaseId);


	TimeIncrementCalculationStrategy* createStrategy(std::string strategy);

private:

	/**
	 * This object holds controller local vision.
	 *
	 * All data measured on sensors or received from tls network
	 * are accessible through this object.
	 */
	localview::LocalView* mLocalView;

	/**
	 * Strategy to calculate phase increment
	 */
	TimeIncrementCalculationStrategy* mActiveCalc;

	std::string mStrategyId;

	CaseFuzzy* mCaseFuzzy;

	int mActivePhaseCalc;

};

#endif
